﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HotelManagement.Class;

namespace HotelManagement
{
    public partial class RetrieveHousekeepingSchedule : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HousekeepingSchedule s = HousekeepingDBManager.getHousekeepingSchedulebyScheduleId(Request.QueryString["scheduleID"]);

            lblSchedID.Text = Request.QueryString["scheduleID"];
            lblDate.Text = s.Date.ToString("d");
            lblDescription.Text = s.Description;
            lblGmStaffID.Text = s.GeneralMaintenanceStaffID;
            lblRmStaffID.Text = s.RoomMaintenanceStaffID;
            lblSmStaffID.Text = s.SecurityMaintenanceStaffID;
            lblEmStaffID.Text = s.EstateMaintenanceStaffID;
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            //go to update page with queryString schedule id
            Server.Transfer("UpdateHousekeepingSchedule.aspx?scheduleID=" + lblSchedID.Text);
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
            deleteHousekeepingSchedule();
        }

        private void deleteHousekeepingSchedule()
        {
            try
            {
                string deleteHsSchedule = lblSchedID.Text;

                //Call Delete housekeeping method
                int row = HousekeepingDBManager.deleteHousekeepingSchedule(deleteHsSchedule);

                if (row > 0)
                {
                    lblStatus.Text = "Delete successful";
                }
                else
                {
                    lblStatus.Text = "Delete unsuccessful. Please select schedule to delete.";
                }
            }
            catch (Exception)
            {
                lblStatus.Text = "Sorry, This Schedule cannot be deleted.";
            }
        }

        protected void btnGoBack_Click(object sender, EventArgs e)
        {
            Server.Transfer("ManageHousekeepingAndStaff.aspx");
        }
    }
}